<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>1-删除子节点</title>
	</head>
	<body>
		<button>删除</button>
		<ul>
			<li>百度</li>
			<li>新浪</li>
			<li>阿里</li>
		</ul>
		<script type="text/javascript">
			//方法 Node.removeChild()
			//1.获取事件源对象
			var btn = document.querySelector('button');
			//获取ul元素对象
			var ul = document.querySelector('ul');
			//2.事件类型
			btn.onclick = function(){
				//判断是否还有子节点
				if(ul.children.length==0){
					alert('没了');
					return;
				}
				//alert(1);
				ul.removeChild(ul.children[0]);
			}
		</script>
	</body>
</html>
